package com.xfxz.merchant.view.attention;

import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.xfxz.merchant.R;
import com.xfxz.merchant.adapter.AttentionAdapter;
import com.xfxz.merchant.adapter.CollectAdapter;
import com.xfxz.merchant.myapplication.BaseActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindColor;
import butterknife.BindView;
import butterknife.ButterKnife;

public class AttentionCollectionActivity extends BaseActivity implements RadioGroup.OnCheckedChangeListener {

    @BindView(R.id.rg_attention_collect)
    public RadioGroup mRadioGroup;
    @BindView(R.id.rb_attention_collect_attention)
    public RadioButton mRbAttention;
    @BindView(R.id.rb_attention_collect_collect)
    public RadioButton  mRbCollect;
    @BindView(R.id.tv_attention_collect_num)
    public TextView mTvNum;
    @BindView(R.id.tv_attention_collect_count)
    public TextView mTvCount;
    @BindView(R.id.lv_attention_collect_attention)
    public ListView mLvAttention;
    @BindView(R.id.lv_attention_collect_collect)
    public ListView mLvCollect;
    @BindColor(R.color.login_tags_righttext)
    public int red;
    @BindColor(R.color.colorPrimaryDark)
    public int black;
    @BindColor(R.color.colorWhite)
    public int white;
    private List<String> mAttentionData;
    private List<String> mCollectData;
    private AttentionAdapter mAttentionAdapter;
    private CollectAdapter mCollectAdapter;
    private int attentionCount, collectCount;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        BaseSetContentView(R.layout.activity_attention_collection);
        ButterKnife.bind(this);
        setBarTitle("关注/收藏管理");
        setBarBackgroundColor(white);
        isBarBackShow(true);
        mRadioGroup.setOnCheckedChangeListener(this);
        mAttentionData = new ArrayList<>();
        mAttentionAdapter = new AttentionAdapter(this, mAttentionData);
        mLvAttention.setAdapter(mAttentionAdapter);
        mCollectData = new ArrayList<>();
        mCollectAdapter = new CollectAdapter(this, mCollectData);
        mLvCollect.setAdapter(mCollectAdapter);
        loadData();
    }

    private void loadData() {
        for (int i = 0; i < 20; i++) {
            mAttentionData.add("关注用户"+i);
            mCollectData.add("收藏用户"+i);
        }
        attentionCount = mAttentionData.size();
        mTvCount.setText(attentionCount+"人");
        collectCount = mCollectData.size();
        mAttentionAdapter.notifyDataSetChanged();
        mCollectAdapter.notifyDataSetChanged();
    }


    @Override
    public void onBarBackClickListener() {
        super.onBarBackClickListener();
        finish();
    }

    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        switch (checkedId) {
            case R.id.rb_attention_collect_attention:
                mRbAttention.setTextColor(red);
                mRbCollect.setTextColor(black);
                mTvNum.setText("关注人数：");
                mTvCount.setText(attentionCount+"人");
                mLvAttention.setVisibility(View.VISIBLE);
                mLvCollect.setVisibility(View.GONE);
                break;
            case R.id.rb_attention_collect_collect:
                mRbCollect.setTextColor(red);
                mRbAttention.setTextColor(black);
                mTvNum.setText("收藏人数：");
                mTvCount.setText(collectCount+"人");
                mLvCollect.setVisibility(View.VISIBLE);
                mLvAttention.setVisibility(View.GONE);
                break;
            default:
                break;
        }
    }
}
